<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <title>登陆界面</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
    <link rel="stylesheet" href="/lib/layui/css/layui.css">
</head>
<body>
<form class="layui-form" action="/login" id="login-form" method="post" style="margin: 100px auto;width: 500px;">
    <div class="layui-form-item">
        <label class="layui-form-label">账户</label>
        <div class="layui-input-inline">
            <input type="text" name="username" required="required" lay-verify="required" placeholder="请输入账户"
                   autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-inline">
            <input type="password" name="password" required="required" lay-verify="required" placeholder="请输入密码"
                   autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">请输入密码！！</div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" type="button" lay-submit lay-filter="formSubmit">登陆</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script type="text/javascript" src="/lib/layui/layui.all.js"></script>
<script type="text/javascript" src="/lib/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="/lib/jquery.form.js"></script>
<script type="text/javascript">
    layui.use('form', function () {
        var form = layui.form;
        //监听提交
        form.on('submit(formSubmit)', function (data) {
            $("#login-form").ajaxSubmit({
                success: function (data) {
                    if (data.code === "200") {
                        layer.msg("登陆成功");
                        return false;
                    } else {
                        layer.msg(data.msg);
                    }
                }
            })
        });
    });
</script>
</body>
</html>